package com.bite.ioc.controller;

import com.bite.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class HelloController {
    @Autowired
    private UserService userService;



//    private UserComponent userComponent;

    public HelloController() {
    }

    @Autowired
    public HelloController(UserService userService) {
        this.userService = userService;
    }
//    @Autowired
//    public HelloController(UserService userService, UserComponent userComponent) {
//        this.userService = userService;
//        this.userComponent = userComponent;
//    }

    //Setter方法注入
    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void sayHi(){
        userService.doService();
//        userComponent.doComponent();
        System.out.println("hi, helloController...");
    }
}
